package d.n.d.dao;

import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import org.springframework.stereotype.Repository;
import d.n.d.domain.Customer;

@Repository
public class CustomerDaoImpl implements CustomerDao {

	@PersistenceContext
	private EntityManager em;

	/**
	 * <br> Author: DucDS. </br>
	 * @return List<Customer>
	 */
	public List<Customer> getAllCustomer() {

		TypedQuery<Customer> query = em.createQuery(
				"SELECT cus FROM Customer cus ", Customer.class);
		return query.getResultList();
	}

	/**
	 * @return Customer
	 */
	public Customer getCustomerById(int customerId) {

		return em.find(Customer.class, customerId);
	}
}
